public class Test {
    public static void main(String[] args) {
        Person p1 = new Person();
        System.out.println(p1 instanceof Person);
        Person s1 = new Student();
        System.out.println(s1 instanceof Person);
        check_instanceof(p1); // 不会打印
        check_instanceof(s1); 
    }

    public static void check_instanceof(Person p) {
        // 1、手动拆箱： 类型转换
        if (p instanceof Student) {
            ((Student) p).go_to_school();
        }
        // 2、使用自动拆箱
        if (p instanceof Student s) {
            s.go_to_school();
        }
    }
}

class Person {
    public void run() {
        System.out.println("Person is runing");
    }
}

class Student extends Person {
    @Override
    public void run() {
        System.out.println("Student is runing");
    }

    public void go_to_school() {
        System.out.println("Student is go_to_school");
    }
}